/**
 * node-event-extend.js
 */
const EventEmitter = require ("event").EventEmitter;

function Dog(aogName){
    /**
     * Function.call 会执行一次Function函数
     * 并且函数执行的上下文是当前的Dog构造函数实例化的对象
     */
    EventEmitter.call(this);
    this.dogname = this.dogname;
    setTimeout(() => {
        this.emit("bark");
    },3000)
}
Dog.prototype = EventEmitter.prototype;
let dog = new Dog("zangao");

dog.on("bark",() => {
    console.log("dog is barking");
})